package ar.com.fiuba;

import java.io.IOException;

import ar.com.fiuba.domain.api.Corrector;
import ar.com.fiuba.domain.impl.ErrorGeneratorDeletion;
import ar.com.fiuba.domain.impl.ErrorGeneratorInsertion;
import ar.com.fiuba.domain.impl.ErrorGeneratorSubstitution;
import ar.com.fiuba.domain.impl.ErrorGeneratorTransposition;

public class ReportGenerator {
	
	Corrector corrector;
	String filename;
	int numberOfWords;
	
	public ReportGenerator(Corrector corrector, String filename, int nOfWords)
	{
		this.corrector = corrector;
		this.filename = filename;
		this.numberOfWords = nOfWords;
	}
	
	public void generateReports() throws IOException
	{
		
		TestRunner testsInsertion = new TestRunner(corrector,numberOfWords,new ErrorGeneratorInsertion(filename,numberOfWords), "insertionErrors");
		
		try {
			testsInsertion.runTest();
			System.out.println("Porcentaje de aciertos ERRORES DE INSERCION:" + testsInsertion.getPercentageOfCorrectWords());
		} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		}
	
	
		TestRunner testsDeletion = new TestRunner(corrector,20,new ErrorGeneratorDeletion(filename,numberOfWords), "deletionErrors");
		
		try {
			testsDeletion.runTest();
			System.out.println("Porcentaje de aciertos ERRORES DE BORRADO:" + testsDeletion.getPercentageOfCorrectWords());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		TestRunner testsSubstitution = new TestRunner(corrector,20,new ErrorGeneratorSubstitution(filename,numberOfWords), "substitutionErrors");
		
		try {
			testsSubstitution.runTest();
			System.out.println("Porcentaje de aciertos ERRORES DE SUBSTITUCION:" + testsSubstitution.getPercentageOfCorrectWords());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		TestRunner testsTransposition = new TestRunner(corrector,20,new ErrorGeneratorTransposition(filename,numberOfWords), "transpositionErrors");
		
		try {
			testsTransposition.runTest();
			System.out.println("Porcentaje de aciertos ERRORES DE TRANSPOSICION:" + testsTransposition.getPercentageOfCorrectWords());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("*************RESUMEN DE RESULTADOS***************");
		System.out.println("Porcentaje de aciertos ERRORES DE INSERCION: " + testsInsertion.getPercentageOfCorrectWords());
		System.out.println("Porcentaje de aciertos ERRORES DE BORRADO: " + testsDeletion.getPercentageOfCorrectWords());
		System.out.println("Porcentaje de aciertos ERRORES DE SUBSTITUCION: " + testsSubstitution.getPercentageOfCorrectWords());
		System.out.println("Porcentaje de aciertos ERRORES DE TRANSPOSICION: " + testsTransposition.getPercentageOfCorrectWords());
	}
}


